//
//  RecommentDeatilCell.m
//  Otaku
//
//  Created by lanou3g on 16/5/7.
//  Copyright © 2016年 Liuwx. All rights reserved.
//

#import "RecommentDeatilCell.h"

@interface RecommentDeatilCell ()
@property (weak, nonatomic) IBOutlet UIImageView *User_Name;
@property (weak, nonatomic) IBOutlet UIButton *Goode;

@property (weak, nonatomic) IBOutlet UILabel *User_name;

@property (weak, nonatomic) IBOutlet UILabel *User_text;
@property (weak, nonatomic) IBOutlet UILabel *creat_time;



@end

@implementation RecommentDeatilCell

- (void)awakeFromNib {
    // Initialization code
}

-(void)layoutSubviews
{
    [self.User_Name sd_setImageWithURL:[NSURL URLWithString:self.getmodel.avatar_url]];
    self.User_Name.layer.cornerRadius = 15;
    
    self.User_name.text = self.getmodel.user_name;
    self.User_text.text = self.getmodel.text;
    
    self.creat_time.text = [NSString stringWithFormat:@"%ld",(long)self.getmodel.create_time];
    
    [self.Goode setTitle:[NSString stringWithFormat:@"%ld",(long)self.getmodel.digg_count] forState:(UIControlStateNormal)];
    NSString *path1 = [[NSBundle mainBundle] pathForResource:@"digupicon_comment_press@3x" ofType:@"png"];
    UIImage *image1 = [[UIImage alloc] initWithContentsOfFile:path1];
    [self.Goode setImage:image1  forState:(UIControlStateNormal)];
}
- (IBAction)Goode:(UIButton *)sender {
    NSString *path = [[NSBundle mainBundle] pathForResource:@"add_one@3x" ofType:@"png"];
    UIImage *image = [[UIImage alloc] initWithContentsOfFile:path];
    UIImageView *imgView = [[UIImageView alloc]initWithImage:image];
    imgView.alpha = 1;
    [sender addSubview:imgView];
    
    if (sender.selected) {
        
        [self.Goode setTitle:[NSString stringWithFormat:@"%ld",(long)self.getmodel.digg_count+1] forState:(UIControlStateNormal)];
        [UIView animateWithDuration:1 animations:^{
            imgView.alpha = 0;
        } completion:^(BOOL finished) {
            [imgView removeFromSuperview];
            
        }];
        
    }
    else
    {
        UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"" message:@"你已经选择" preferredStyle:(UIAlertControllerStyleAlert)];
        [alertVC addAction:[UIAlertAction actionWithTitle:@"知道了" style:(UIAlertActionStyleDefault) handler:nil]];
        
        [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alertVC animated:YES completion:nil];
        
    }

}
+ (CGFloat)heightModel:(ZLW_RecommmentDetailModel *)model
{
    CGFloat heightContent = [Tool labelHeightWithText:model.text font:[UIFont systemFontOfSize:17]];
    
    return 100+heightContent ;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
